<?php
echo "Student list:<br>";
include('Student.php');
include('Course.php');

$course1 = new Course("001", "Introduction to Computer Science", 3);
$course2 = new Course("002", "Advanced Mathematics", 4);
$course3 = new Course("003", "College Physics", 3);
$course4 = new Course("004", "College English", 2);

$students = array();

$first = new Student("Doe", "John", "Junior");
$first->add_email('home', 'john@doe.com');
$first->add_email('work', 'jdoe@mcdonalds.com');
$first->add_grade($course1,85);
$first->add_grade($course2,75);
$first->add_grade($course4,55);
$students['j123'] = $first;

$second = new Student("Einstein", "Albert", "Senior");
$second->add_email('home', 'albert@braniacs.com');
$second->add_email('work1', 'a_einstein@bcit.ca');
$second->add_email('work2', 'albert@physics.mit.edu');
$second->add_grade($course2,95);
$second->add_grade($course3,80);
$second->add_grade($course4,50);
$students['a456'] = $second;

$third = new Student("Yaoyu","Jiang","Freshman");
$third->add_email('home','cabtie@163.com');
$third->add_grade($course1,80);
$third->add_grade($course3,75);
$third->add_grade($course4,55);
$students['y246'] = $third;

$fourth = new Student("Junior","Bill","Sophomore");
$fourth->add_email('home','gates@microsoft.com');
$fourth->add_grade($course1,95);
$fourth->add_grade($course2,85);
$fourth->add_grade($course3,90);
$students['b401'] = $fourth;

ksort($students);

foreach ($students as $student){
    echo $student->toString();
}